home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-10-09 | 808 b | 34 lines | [TEXT/MEDT] |
- MODULE FileExample;
-
- (* this program copies the file "Example.TXT" into the file "Copy.BAK". *)
- (* demonstrates the access to text files. *)
-
- FROM FileSystem IMPORT File, Response, Lookup, Close, ReadChar, WriteChar;
-
- VAR f,g: File;
- ch: CHAR;
-
- BEGIN
- (* Open existing file f *)
- Lookup(f,"Example.TXT",FALSE);
- IF f.res = done THEN
- (* Create new file g *)
- Lookup(g,"Copy.BAK",TRUE);
- IF g.res = done THEN
- (* Copy f to g *)
- LOOP
- ReadChar(f,ch);
- IF f.eof THEN EXIT END;
- WriteChar(g,ch);
- END (* LOOP *);
- Close(g);
- ELSE
- (* File g could not be created (disk full?). *)
- END (* IF *);
- Close(f);
- ELSE
- (* File f could not be opened (not existent?). *)
- END (* IF *);
- END FileExample.
-
-